home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v9n05.arc / INIT87.ASM < prev    next >
Assembly Source File  |  1990-02-13  |  2KB  |  54 lines

  1.         title   INIT87.ASM Initialize Numeric Coprocessor
  2.         page    55,132
  3.  
  4. ; INIT87.ASM    Initialize 80x87 Numeric Coprocessor
  5. ;
  6. ; Copyright (C) 1989 Ziff Davis Communications
  7. ; PC Magazine * Ray Duncan
  8. ;
  9. ; Call with:    AX      = control word for desired rounding
  10. ;                         mode, precision, exception mask
  11. ;
  12. ; Returns:      (if coprocessor present)
  13. ;               Z flag  = True (1)
  14. ;
  15. ;               (if coprocessor not found)
  16. ;               Z flag  = False (0)
  17. ;
  18. ; Destroys:     nothing
  19.  
  20. _TEXT   segment word public 'CODE'
  21.  
  22.         assume  cs:_TEXT
  23.  
  24.         public  init87
  25. init87  proc    near
  26.  
  27.         push    bx                      ; save registers
  28.         push    ax
  29.  
  30.         mov     ax,-1                   ; put FFFFH on stack
  31.         push    ax
  32.         mov     bx,sp                   ; make it addressable
  33.  
  34.         fninit                          ; try to initialize coprocessor
  35.         fnstsw  ss:[bx]                 ; try to get status word
  36.         
  37.         pop     ax                      ; if low 8 bits are zero,
  38.         or      al,al                   ; coprocessor is present
  39.  
  40.         jnz     initx                   ; jump if no coprocessor
  41.  
  42.         fldcw   ss:[bx+2]               ; load coprocessor control word
  43.  
  44. initx:  pop     ax                      ; restore registers
  45.         pop     bx
  46.         ret                             ; and return result in Z flag
  47.  
  48. init87  endp
  49.  
  50. _TEXT   ends
  51.  
  52.         end
  53.  
  54.